﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WorkStation.Frameworks.EasyBus.Pipeline.Modules;

namespace WorkStation.Frameworks.EasyBus.Pipeline
{
    /// <summary>
    /// 管道接口
    /// </summary>
    public interface IPipeline
    {
        event Action<ActionContext, SuccessHandleResult> OnSuccess;
        event Action<ActionContext, FailHandleResult> OnFail;
        event Action<ActionContext> OnPublishBefore;
        event Action<ActionContext, IEnumerable<HandleResult>> OnPublishAfter;

        Dictionary<string, IModule> Modules { get; set; }

        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="context">执行上下文</param>
        /// <returns></returns>
        IEnumerable<HandleResult> Publish(ActionContext context);

        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="input">输入对象</param>
        /// <returns></returns>
        IEnumerable<HandleResult> Publish(object input);
    }
}
